package com.limh.jkzs.base

import android.content.Intent
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast

/**
 * Function:
 * author: limh
 * time:2018/1/17
 */
abstract class BaseFragment : Fragment() {

    public var TAG: String = "BaseFragment"

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        val view: View = inflater.inflate(findView(), container, false)
        TAG = this.javaClass.simpleName
        initView(view)
        return view
    }

    abstract fun findView(): Int

    abstract fun initView(view: View)

    fun showLong(msg: String) = Toast.makeText(this.context!!.applicationContext, msg, Toast.LENGTH_LONG).show()
    fun showShort(msg: String) = Toast.makeText(this.context!!.applicationContext, msg, Toast.LENGTH_SHORT).show()

    fun openActivity(cls: Class<*>) {
        val intent = Intent(context, cls)
        startActivity(intent)
    }

}